fix: recording produces correct video duration with real-time ffmpeg encoding#812
Conversation
…cording
Recording previously used Page.captureScreenshot polling at 10fps,
which was CPU-heavy and produced inconsistent results. Now uses
Page.startScreencast with throttled acks (35ms interval) to receive
frames event-driven from Chrome, and pipes JPEG data directly to
ffmpeg stdin in real-time instead of saving temp files.
- Spawn ffmpeg at recording start with piped stdin (image2pipe)
- Background task receives screencast frames, interpolates gaps by
repeating the last frame based on timestamps, targets 25fps
- Ack throttling controls Chrome's frame push rate
- Fix: current frame was never written after the first one
- Fix: frame count was read before task finished padding
- Remove tokio-util dependency (replaced CancellationToken with oneshot)
- Add tokio "process" feature for async child process stdin pipe
- Extract start/stop_recording_task helpers on DaemonState
- Add tests for restart, ffmpeg codec selection, and stop without task
|
@hyunjinee is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
compatibility VP9 realtime encoder ignored input framerate, producing 10fps output instead of 25fps. This caused inconsistent playback in browsers. VP8 respects -framerate 25 and has wider browser playback support.
|
Thanks for this @jin-2-kakaoent! The code quality here is solid — the helper extraction, concurrency patterns, and I ran an end-to-end test and hit a problem: a 3-second recording of a static page produced only a 1.04-second video. Chrome's screencast only pushes frames when the screen changes, so for static or low-activity pages you get almost nothing. The old Screencast is a great fit for live preview, but for recording I think you need regular frame capture to guarantee correct duration and timing. |
…ing duration Screencast only pushes frames on visual changes, producing short videos on static pages. Screenshot polling captures at a fixed 10fps interval regardless of page activity, guaranteeing duration matches wall-clock time. ffmpeg piped stdin architecture is preserved — no temp files.
|
@ctate Thanks for the review! As you pointed out, screencast only pushes frames on visual changes, so static pages produce short videos. I've switched the frame source from The piped ffmpeg architecture is preserved — screenshots are decoded and written directly to ffmpeg stdin, no temp files. Test results for 10 seconds video are attached below. mp4 10s-test.mp4webm 10s-test.webm |
|
Works great. Thanks you @jin-2-kakaoent |
Closes #811
Summary
image2pipe), capture screenshots at a fixed 10fps interval viaPage.captureScreenshot, and stream JPEG frames directly to ffmpeg in real-time — no temp filesstart_recording_task/stop_recording_taskhelpers onDaemonStateto eliminate duplication across 5 handlerskill_on_drop(true)to ffmpeg process to prevent zombie on task panicTest plan
record start/stopwith.webm(VP8) — 10s recording produces 11.0s videorecord start/stopwith.mp4(H.264) — 10s recording produces 11.0s videoffprobeconfirms correct codec, framerate (10fps), and duration for both formats